﻿<Window x:Class="Brjnk.GpxExplorer.UI.CheckNewVersionWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:l="clr-namespace:Brjnk.GpxExplorer.Localization"
        Title="{l:Loc titleCheckNewVersion}"
        MinWidth="300" ResizeMode="NoResize" SizeToContent="WidthAndHeight"
        FocusManager.FocusedElement="{Binding ElementName=okButton}"
        WindowStartupLocation="CenterOwner"
        WindowStyle="ToolWindow"
        DataContext="{Binding RelativeSource={RelativeSource Mode=Self}}">
    <StackPanel>
        <StackPanel.Resources>
            <Style TargetType="TextBlock">
                <Style.Triggers>
                    <Trigger Property="Text" Value="">
                        <Setter Property="Visibility" Value="Collapsed" />
                    </Trigger>
                </Style.Triggers>
            </Style>
        </StackPanel.Resources>

        <!--Probíhá zjišťování nové verze-->
        <StackPanel Orientation="Vertical" Visibility="{Binding Path=InProgress, Converter={StaticResource BooleanToVisibilityConverter}}">
            <TextBlock Text="{l:Loc checkVersionInProgress}" Style="{StaticResource HeaderStyle}" />
            <ProgressBar Height="20" IsIndeterminate="true" />
        </StackPanel>

        <!--Nová verze je dostupná-->
        <StackPanel Visibility="{Binding NewVersionAvailable, Converter={StaticResource BooleanToVisibilityConverter}}">
            <TextBlock Background="LightGreen" Style="{StaticResource HeaderStyle}" Text="{l:Loc checkVersionNewVersionAvailable}" />
            <TextBlock Text="{Binding NewerVersion}" />
            <TextBlock FontSize="20" Text="http://gpxexplorer.codeplex.com/" Style="{StaticResource LinkStyle}" />
        </StackPanel>

        <!--Nová verze není dostupná-->
        <TextBlock Visibility="{Binding NewVersionUnavailable, Converter={StaticResource BooleanToVisibilityConverter}}"
            Text="{l:Loc checkVersionNewVersionUnavailable}" Style="{StaticResource HeaderStyle}" />
        <!--Zprávy-->
        <ItemsControl ItemsSource="{Binding Messages}">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Item1}" TextWrapping="Wrap" Foreground="{Binding Item2}" />
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
        <!--Fail-->
        <TextBlock Text="{l:Loc checkVersionFailed}" Style="{StaticResource ErrorStyle}" Visibility="{Binding Failed, Converter={StaticResource BooleanToVisibilityConverter}}" />
        <Button Name="okButton" Content="{l:Loc ok}" HorizontalAlignment="Right" Click="Button_Click"></Button>
    </StackPanel>
</Window>